/**
 * 宿舍管理人员的简单包装，将操作与数据分离，使得层次更为清晰
 * 该类
 */
package dms.model.role.wrapper;

import java.text.ParseException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import dms.dto.BulletinDTO;
import dms.dto.DormSupervisorDTO;
import dms.dto.LowElectricityDTO;
import dms.dto.MailDTO;
import dms.dto.NoticeDTO;
import dms.model.Dormitory;
import dms.model.exception.NoPermissionException;
import dms.model.exception.NoSuchEntityException;
import dms.model.form.Bulletin;
import dms.model.form.FoundNotice;
import dms.model.form.LostNotice;
import dms.model.form.LowElectricity;
import dms.model.form.Mail;
import dms.model.form.Notice;
import dms.model.form.PurchaseItem;
import dms.model.form.Repair;
import dms.model.role.DormSupervisor;
import dms.repository.BulletinRepository;
import dms.repository.DormitoryRepository;
import dms.repository.LowElectricityRepository;
import dms.repository.MailRepository;
import dms.repository.NoticeRepository;
import dms.repository.PurchaseItemRepository;
import dms.repository.RepairRepository;
import dms.repository.SystemAdministratorRepository;
import dms.util.DateFormatUtil;
import dms.util.PasswordUtil;

/**
 * 宿舍管理人员的简单包装，将操作与数据分离，使得层次更为清晰
 * 该类负责DormSupervisor的业务操作，内部的dormSupervisor为
 * 实体数据，该类中的操作需要用的dormSupervisor的数据，因此
 * 该类是有状态类，每一个session对应一个实例(instance)
 * 
 * @author 李健
 *
 */
public class DormSupervisorWrapper {

	//DormSuerpvisor实体数据
	private DormSupervisor dormSupervisor = null;
	
	//宿舍物业管理用到的仓储
	private MailRepository mailRepository = null;
	private PurchaseItemRepository purchaseItemRepository = null;
	private NoticeRepository noticeRepository = null;
	private BulletinRepository bulletinRepository = null;
	private SystemAdministratorRepository systemAdministratorRepository = null;
	private DormitoryRepository dormitoryRepository = null;
	private RepairRepository repairRepository = null;
	private LowElectricityRepository lowElectricityRepository = null;
	
	/**
	 * @throws Exception *****************************************************************************************/
	// Domain operation 
	
	/**
	 * 新增邮件
	 */
	public Mail addMail(MailDTO mailInfo) throws Exception {
		Mail mail = new Mail();
		Dormitory dormitory = this.dormitoryRepository.findByBuildingAndName(this.getDormSupervisor().getBuilding(), 
																			 mailInfo.getDormitory().toString());
		if (dormitory == null) {
			throw new NoSuchEntityException("没有该寝室");
		}
		
		if (mailInfo.getArriveDate() != null) {
			mail.setArriveDate(mailInfo.getArriveDate());
		} else {
			mail.setArriveDate(new Date());
		}
		
		mail.setDescription(mailInfo.getDescription());
		mail.setDormitory(dormitory);
		mail.setStudent(mailInfo.getStudent());
		
		return this.mailRepository.createMail(mail);
	}
	
	/**
	 * 修改已有邮件信息，会进行权限检查
	 * @param mailInfo
	 * @return
	 * @throws Exception
	 */
	public Mail updateMail(MailDTO mailInfo) throws Exception {
		Mail mail = this.mailRepository.findById(mailInfo.getId());		
		
		if (mail == null) {
			throw new NoSuchEntityException("没有该实体");
		}
		if (!mail.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限进行修改");
		}
		Dormitory dormitory = this.dormitoryRepository.findByBuildingAndName(
				this.getDormSupervisor().getBuilding(), mailInfo.getDormitory()
						.toString());
		if (dormitory == null) {
			throw new NoSuchEntityException("没有该寝室");
		}

		if (mailInfo.getArriveDate() != null) {
			mail.setArriveDate(mailInfo.getArriveDate());
		}
		mail.setDescription(mailInfo.getDescription());
		mail.setDormitory(dormitory);
		mail.setStudent(mailInfo.getStudent());
		
		return this.mailRepository.updateMail(mail);

	}
	
	/**
	 * 删除一些邮件，会进行权限检查
	 * @param ids
	 * @throws Exception
	 */
	public void deleteMailes(List<Long> ids) throws Exception {
		Iterator<Long> iter = ids.iterator();
		
		while (iter.hasNext()) {
			Long id = iter.next();
			Mail mail = this.mailRepository.findById(id);
			if (mail != null) {
				if (!mail.getDormitory().getBuilding().getId().equals(
						this.getDormSupervisor().getBuilding().getId())) {
					throw new NoPermissionException("你没有权限进行修改");
				}
			} else {
				throw new NoPermissionException("你没有权限进行修改");
			}
		}
		this.mailRepository.deleteMails(ids);
	}
	
	/**
	 * 删除某个mail,会进行权限检查
	 * @param id
	 * @throws Exception
	 */
	public void deleteMailById(Long id) throws Exception {
		Mail mail = this.mailRepository.findById(id);
		if (mail == null) {
			throw new NoSuchEntityException("没有该实体");
		}
		if (!mail.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限进行修改");
		}
		
		this.mailRepository.deleteById(id);
	}
	
/*	public PageIterator<Mail> findMail(Date fromDate, Date toDate) {
		
		
	}*/
	
	public void deletePurchaseItems(List<Long> ids) throws Exception {
		Iterator<Long> iter = ids.iterator();
		
		while (iter.hasNext()) {
			Long id = iter.next();
			PurchaseItem purchaseItem = this.purchaseItemRepository.findById(id);
			if (purchaseItem != null) {
				if (!purchaseItem.getDormitory().getBuilding().getId().equals(
						this.getDormSupervisor().getBuilding().getId())) {
					throw new NoPermissionException("你没有权限受理");
				}
			} else {
				return ;
			}
		}
		
		this.purchaseItemRepository.deletePurchaseItems(ids);
	}
	
	public void deletePurchaseItemById(Long id) throws Exception {
		PurchaseItem purchaseItem = this.purchaseItemRepository.findById(id);
		
		if (purchaseItem == null) {
			throw new NoSuchEntityException("没有该实体");
		}
		if (!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限受理");
		}
		
		this.purchaseItemRepository.deletePurchaseItemById(id);
	}
	/**
	 * 开始处理purchaseItem
	 * @param purchaseItem
	 * @throws Exception
	 */
	public void processPurchaseItem(PurchaseItem purchaseItem) throws Exception {
		if (!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限受理");
		}
		
		purchaseItem.process();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
	}
	
	public void processPurchaseItem(long purchaseItemId) throws Exception {
		PurchaseItem purchaseItem = this.purchaseItemRepository.findById(purchaseItemId);
		
		if (purchaseItem == null) {
			throw new NoSuchEntityException("没有找到该实体");
		}
		if (!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限受理");
		}
		
		purchaseItem.process();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
	}
	
	/**
	 * 取消受理维修单
	 * @param repairId
	 * @throws Exception
	 */
	public void cancelProcessRepair(long repairId) throws Exception {
		Repair repair = this.repairRepository.findById(repairId);
		
		if (repair == null) {
			throw new NoSuchEntityException("没有找到维修单");
		}
		
		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限修改该维修单");
		}
		
		repair.unProcess();
		this.repairRepository.updateRepair(repair);
	}
	
	/**
	 * 取消已经处理repair的状态不影响受理状态
	 * @param repairId
	 * @throws Exception
	 */
	public void cancelApplyRepair(long repairId) throws Exception {
		Repair repair = this.repairRepository.findById(repairId);
		if (repair == null) {
			throw new NoSuchEntityException("没有找到维修单");
		}
		
		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限修改该维修单");
		}
		repair.unApply();
		this.repairRepository.updateRepair(repair);
	}
	
	/**
	 * 取消受理
	 * @param purchaseItemId
	 * @throws Exception
	 */
	public void cancelProcessPurchase(long purchaseItemId) throws Exception {
		PurchaseItem purchaseItem = this.purchaseItemRepository.findById(purchaseItemId);
		
		if (purchaseItem == null) {
			throw new NoSuchEntityException("没有找到购置单");
		}
		
		if(!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限修改该购置单");

		}
		
		purchaseItem.unProcess();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
		
	}
	
	public void cancelApplyPurchase(long purchaseItemId) throws Exception {
		PurchaseItem purchaseItem = this.purchaseItemRepository.findById(purchaseItemId);
		
		if (purchaseItem == null) {
			throw new NoSuchEntityException("没有找到购置单");
		}
		
		if(!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限修改该购置单");

		}
		
		purchaseItem.unApply();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
		
	}
	
	/**
	 * 已经处理完purchaseItem
	 * @param purchaseItem
	 * @throws Exception
	 */
	public void applyPurchaseItem(PurchaseItem purchaseItem) throws Exception {
		if (!purchaseItem.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限受理");
		}
		
		purchaseItem.apply();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
	}
	
	public void applyPurchaseItem(long purchaseItemId) throws Exception {
		PurchaseItem purchaseItem = this.purchaseItemRepository.findById(purchaseItemId);

		if (purchaseItem == null) {
			throw new NoSuchEntityException("没有找到该实体");
		}

		if (!purchaseItem.getDormitory().getBuilding().getId().equals(
				this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你没有权限受理");
		}

		purchaseItem.apply();
		this.purchaseItemRepository.updatePurchaseItem(purchaseItem);
	}
	
	public void processRepair(Repair repair) throws Exception {
		
		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限受理");
		}
		
		repair.process();
		this.repairRepository.updateRepair(repair);
	}
	
	public void processRepair(long repairId) throws Exception {
		Repair repair = this.repairRepository.findById(repairId);
		
		if (repair == null) {
			throw new NoSuchEntityException("没有该实体");
		}
		
		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限受理");
		}
		
		repair.process();
		this.repairRepository.updateRepair(repair);
	}
	
	public void applyRepair(Repair repair) throws Exception {

		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限受理");
		}
		
		repair.apply();
		this.repairRepository.updateRepair(repair);
	}
	
	public void applyRepair(long repairId) throws Exception {
		Repair repair = this.repairRepository.findById(repairId);
		
		if (repair == null) {
			throw new NoSuchEntityException("没有该实体");
		}
		
		if (!repair.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限受理");
		}
		
		repair.apply();
		this.repairRepository.updateRepair(repair);
	}	
	
	public void deleteRepairById(Long id) throws Exception {
		Repair repair = this.repairRepository.findById(id);
		
		if (repair != null) {
			if (!repair.getBuilding().getId().equals(
					this.getDormSupervisor().getBuilding().getId())) {
				throw new NoPermissionException("没有权限删除");
			}
		} else {
			throw new NoSuchEntityException("没有该实体");
		}
		this.repairRepository.deleteRepairById(id);
	}
	
	public void deleteRepairs(List<Long> ids) throws Exception {
		Iterator<Long> iter = ids.iterator();
		
		while (iter.hasNext()) {
			Long id = iter.next();
			Repair repair = this.repairRepository.findById(id);
			if (repair != null) {
				if (!repair.getBuilding().getId().equals(
						this.getDormSupervisor().getBuilding().getId())) {
					throw new NoPermissionException("没有权限删除");
				}
			} else {
				throw new NoSuchEntityException("没有该实体");
			}
		}
		
		this.repairRepository.deleteRepairs(ids);
	}
	
	public void modifyPersonalInfo(DormSupervisorDTO dormSupervisorInfo) throws NoPermissionException {
		
		if (!dormSupervisorInfo.getId().equals(this.getDormSupervisor().getId())) {
			throw new NoPermissionException("没有权限修改");
		}
		
		if (dormSupervisorInfo.getOldEmail() != null 
				&& dormSupervisorInfo.getEmail() != null
				&& dormSupervisorInfo.getOldEmail().length() != 0
				&& dormSupervisorInfo.getEmail().length() != 0) {
			if (dormSupervisorInfo.getOldEmail().equals(this.getDormSupervisor().getAccount().getEmail())) {
				this.getDormSupervisor().getAccount().setEmail(dormSupervisorInfo.getEmail());
			}
		}
		
		//检验的时候旧密码要MD5
		if (dormSupervisorInfo.getOldPassword() != null 
				&& dormSupervisorInfo.getPassword() != null
				&& dormSupervisorInfo.getOldPassword().length() != 0
				&& dormSupervisorInfo.getPassword().length() != 0) {
			String oldPassword = PasswordUtil.MD5Digest(dormSupervisorInfo.getOldPassword());
			if (oldPassword.equals(this.getDormSupervisor().getAccount().getPassword())) {
				this.getDormSupervisor().getAccount().setPassword(PasswordUtil.MD5Digest(dormSupervisorInfo.getPassword()));
			}
		}
		
		if (dormSupervisorInfo.getTelephone() != null) {
			this.getDormSupervisor().getAccount().setTelephone(dormSupervisorInfo.getTelephone());
		}
		
		this.getDormSupervisor().getAccount().setModifyDate(new Date());
		this.systemAdministratorRepository.updateDormSupervisor(this.getDormSupervisor());
		
	}
	
	public Notice addLostNotice(NoticeDTO noticeInfo) throws Exception {
		Notice notice = new LostNotice();
		notice.setBuilding(this.getDormSupervisor().getBuilding());
		notice.setDescription(noticeInfo.getDescription());
		notice.setPerson(noticeInfo.getPerson());
		notice.setSubtitle(noticeInfo.getSubtitle());
		return this.noticeRepository.createNotice(notice);
	}
	
	public Notice addFoundNotice(NoticeDTO noticeInfo) throws Exception {
		Notice notice = new FoundNotice();
		notice.setBuilding(this.getDormSupervisor().getBuilding());
		notice.setDescription(noticeInfo.getDescription());
		notice.setPerson(noticeInfo.getPerson());
		notice.setSubtitle(noticeInfo.getSubtitle());
		return this.noticeRepository.createNotice(notice);
	}
	
	public Notice updateNotice(NoticeDTO noticeInfo) throws Exception {
		Notice notice = this.noticeRepository.findNoticeById(noticeInfo.getId());
		
		if (notice == null) {
			throw new NoSuchEntityException("没有该实体"); 
		}
		notice.setSubtitle(noticeInfo.getSubtitle());
		notice.setDescription(noticeInfo.getDescription());
		notice.setPerson(noticeInfo.getPerson());
		return this.noticeRepository.updateNotice(notice);
	}
	
	public void applyNotice(long id) throws Exception {
		Notice notice = this.noticeRepository.findNoticeById(id);
		if (notice == null) {
			throw new NoSuchEntityException("没有该实体"); 
		}
		if (!notice.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限修改");
		}
		notice.apply();
		this.noticeRepository.updateNotice(notice);
	}
	
	public void deleteNotices(List<Long> ids) throws Exception {
		Iterator<Long> iter = ids.iterator();
		
		while (iter.hasNext()) {
			Long id = iter.next();
			Notice notice = this.noticeRepository.findNoticeById(id);
			if (notice == null) {
				throw new NoSuchEntityException("没有该实体"); 
			} else {
				if (!notice.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
					throw new NoPermissionException("没有权限修改");
				}
			}
		}
		
		this.noticeRepository.deleteNotices(ids);
	}
	
	public void deleteNoticeById(Long id) throws Exception {
		Notice notice = this.noticeRepository.findNoticeById(id);
		if (notice == null) {
			throw new NoSuchEntityException("没有该实体"); 
		} else {
			if (!notice.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
				throw new NoPermissionException("没有权限修改");
			}
		}
		this.noticeRepository.deleteNoticeById(id);
	}
	
	public Bulletin addBulletin(BulletinDTO bulletinInfo) throws Exception {
		Bulletin bulletin = new Bulletin();
		
		bulletin.setBuilding(this.getDormSupervisor().getBuilding());
		bulletin.setContent(bulletinInfo.getContent());
		bulletin.setDormSupervisor(this.getDormSupervisor());
		bulletin.setPublishDate(new Date());
		bulletin.setTitle(bulletinInfo.getTitle());		
		
		return this.bulletinRepository.createBulletin(bulletin);
	}
	
	public Bulletin updateBulletin(BulletinDTO bulletinInfo) throws Exception {
		Bulletin bulletin = this.bulletinRepository.findById(bulletinInfo.getId());
		
		if (bulletin == null) {
			throw new NoSuchEntityException("没有该实体"); 
		}
		
		if (!bulletin.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限修改");
		}
		
		bulletin.setContent(bulletinInfo.getContent());
		bulletin.setDormSupervisor(this.getDormSupervisor());
		bulletin.setPublishDate(new Date());
		bulletin.setTitle(bulletinInfo.getTitle());
		
		return this.bulletinRepository.updateBulletin(bulletin);
	}
	
	public void deleteBulletins(List<Long> ids) throws Exception {
		Iterator<Long> iter = ids.iterator();
		
		while (iter.hasNext()) {
			Long id = iter.next();
			Bulletin bulletin = this.bulletinRepository.findById(id);
			if (bulletin == null) {
				throw new NoSuchEntityException("没有该实体"); 
			}			
			if (!bulletin.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
				throw new NoPermissionException("没有权限删除");
			}
		}
		
		this.bulletinRepository.deleteBulletins(ids);
	}
	
	public void deleteBulletinById(Long id) throws Exception {
		Bulletin bulletin = this.bulletinRepository.findById(id);
		
		if (bulletin == null) {
			throw new NoSuchEntityException("没有该实体"); 
		}
		
		if (!bulletin.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("没有权限删除");
		}
		
		this.bulletinRepository.deleteBulletinById(id);
	}
	
	public LowElectricity addLowElectricity(LowElectricityDTO lowElectricityInfo) throws Exception {
		LowElectricity lowElectricity = new LowElectricity();
		Dormitory dormitory = null;
		dormitory = this.dormitoryRepository.findByBuildingAndName(this.getDormSupervisor().getBuilding(), lowElectricityInfo.getDormitory());
		
		if (dormitory == null) {
			throw new NoSuchEntityException("没有这个寝室");
		}
		lowElectricity.setDate(DateFormatUtil.parseDate(lowElectricityInfo.getDate()));
		lowElectricity.setDegree(Double.valueOf(lowElectricityInfo.getDegree()));
		lowElectricity.setDormitory(dormitory);
		
		return this.lowElectricityRepository.createLowElectricity(lowElectricity);
	}
	
	public LowElectricity updateLowElectricity(LowElectricityDTO lowElectricityInfo) throws Exception {
		LowElectricity lowElectricity = this.lowElectricityRepository.findById(lowElectricityInfo.getId());
		
		Dormitory dormitory = null;	
		dormitory = this.dormitoryRepository.findByBuildingAndName(this.getDormSupervisor().getBuilding(), lowElectricityInfo.getDormitory());
		if (dormitory == null) {
			throw new NoSuchEntityException("没有名为：" + lowElectricityInfo.getDormitory() + "的寝室");
		}
		if (!dormitory.getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你不是该楼栋的管理员，没有权限修改低电警告");
		}
		lowElectricity.setDate(DateFormatUtil.parseDate(lowElectricityInfo.getDate()));
		lowElectricity.setDegree(Double.valueOf(lowElectricityInfo.getDegree()));
		lowElectricity.setDormitory(dormitory);
		
		return this.lowElectricityRepository.updateLowElectricity(lowElectricity);
	}
	
	public void deleteLowElectricity(List<Long> ids) throws Exception {
		Iterator<Long> idIter = ids.iterator();
		while (idIter.hasNext()) {
			LowElectricity lowElectricity = this.lowElectricityRepository.findById(idIter.next());
			if (lowElectricity == null) {
				throw new NoSuchEntityException("没有ID：" + lowElectricity.getId() + "的低电警告");
			}
			if (!lowElectricity.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
				throw new NoPermissionException("你不是该楼栋的管理员，没有权限删除");
			}
		}
		
		this.lowElectricityRepository.delete(ids);
	}
	
	public void deleteLowElectricity(Long id) throws Exception {
		LowElectricity lowElectricity = this.lowElectricityRepository.findById(id);
		if (lowElectricity == null) {
			throw new NoSuchEntityException("没有ID：" + id + "的低电警告");
		}
		if (!lowElectricity.getDormitory().getBuilding().getId().equals(this.getDormSupervisor().getBuilding().getId())) {
			throw new NoPermissionException("你不是该楼栋的管理员，没有权限删除");
		}
		this.lowElectricityRepository.deleteById(id);
	}
	
	//TODO 还有出入，低电警告的操作尚未加入 

	/**************************************************************************************************/
	/*getter setter method*/ 
	/**
	 * @return the dormSupervisor
	 */
	public DormSupervisor getDormSupervisor() {
		return dormSupervisor;
	}

	/**
	 * @param dormSupervisor the dormSupervisor to set
	 */
	public void setDormSupervisor(DormSupervisor dormSupervisor) {
		this.dormSupervisor = dormSupervisor;
	}

	/**
	 * @return the mailRepository
	 */
	public MailRepository getMailRepository() {
		return mailRepository;
	}

	/**
	 * @param mailRepository the mailRepository to set
	 */
	public void setMailRepository(MailRepository mailRepository) {
		this.mailRepository = mailRepository;
	}

	/**
	 * @return the purchaseItemRepository
	 */
	public PurchaseItemRepository getPurchaseItemRepository() {
		return purchaseItemRepository;
	}

	/**
	 * @param purchaseItemRepository the purchaseItemRepository to set
	 */
	public void setPurchaseItemRepository(
			PurchaseItemRepository purchaseItemRepository) {
		this.purchaseItemRepository = purchaseItemRepository;
	}

	/**
	 * @return the noticeRepository
	 */
	public NoticeRepository getNoticeRepository() {
		return noticeRepository;
	}

	/**
	 * @param noticeRepository the noticeRepository to set
	 */
	public void setNoticeRepository(NoticeRepository noticeRepository) {
		this.noticeRepository = noticeRepository;
	}

	/**
	 * @return the bulletinRepository
	 */
	public BulletinRepository getBulletinRepository() {
		return bulletinRepository;
	}

	/**
	 * @param bulletinRepository the bulletinRepository to set
	 */
	public void setBulletinRepository(BulletinRepository bulletinRepository) {
		this.bulletinRepository = bulletinRepository;
	}

	/**
	 * @return the systemAdministratorRepository
	 */
	public SystemAdministratorRepository getSystemAdministratorRepository() {
		return systemAdministratorRepository;
	}

	/**
	 * @param systemAdministratorRepository the systemAdministratorRepository to set
	 */
	public void setSystemAdministratorRepository(
			SystemAdministratorRepository systemAdministratorRepository) {
		this.systemAdministratorRepository = systemAdministratorRepository;
	}

	/**
	 * 
	 */
	public DormSupervisorWrapper() {
		super();
	}

	/**
	 * @return the dormitoryRepository
	 */
	public DormitoryRepository getDormitoryRepository() {
		return dormitoryRepository;
	}

	/**
	 * @param dormitoryRepository the dormitoryRepository to set
	 */
	public void setDormitoryRepository(DormitoryRepository dormitoryRepository) {
		this.dormitoryRepository = dormitoryRepository;
	}
	/**
	 * @return the repairRepository
	 */
	public RepairRepository getRepairRepository() {
		return repairRepository;
	}

	/**
	 * @param repairRepository the repairRepository to set
	 */
	public void setRepairRepository(RepairRepository repairRepository) {
		this.repairRepository = repairRepository;
	}

	public LowElectricityRepository getLowElectricityRepository() {
		return lowElectricityRepository;
	}

	public void setLowElectricityRepository(
			LowElectricityRepository lowElectricityRepository) {
		this.lowElectricityRepository = lowElectricityRepository;
	}

	/**
	 * @param mailRepository
	 * @param purchaseItemRepository
	 * @param noticeRepository
	 * @param bulletinRepository
	 * @param systemAdministratorRepository
	 * @param dormitoryRepository
	 * @param repairRepository
	 */
	public DormSupervisorWrapper(MailRepository mailRepository,
			PurchaseItemRepository purchaseItemRepository,
			NoticeRepository noticeRepository,
			BulletinRepository bulletinRepository,
			SystemAdministratorRepository systemAdministratorRepository,
			DormitoryRepository dormitoryRepository,
			RepairRepository repairRepository) {
		super();
		this.mailRepository = mailRepository;
		this.purchaseItemRepository = purchaseItemRepository;
		this.noticeRepository = noticeRepository;
		this.bulletinRepository = bulletinRepository;
		this.systemAdministratorRepository = systemAdministratorRepository;
		this.dormitoryRepository = dormitoryRepository;
		this.repairRepository = repairRepository;
	}
}
